import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import Vant from 'vant';
import 'vant/lib/index.css';
import './style/index.css'
// rem适配
import 'amfe-flexible'
// 时间格式化
import moment from 'moment'
import 'moment/locale/zh-cn';
moment.locale('zh-cn');
Vue.prototype.$moment = moment
    // this.$moment(item).format('YYYY-MM-DD')
    // axios配置
import axios from 'axios'
axios.defaults.baseURL = 'http://121.4.40.144'
    //设置axios为form-data
    // axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
    // axios.defaults.headers.get['Content-Type'] = 'application/x-www-form-urlencoded';
axios.defaults.transformRequest = [function(data) {
    let ret = ''
    for (let it in data) {
        ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
    }
    return ret
}]
axios.interceptors.request.use(config => {
    if (localStorage.getItem('token')) {
        // config.headers.Authorization = localStorage.getItem('token')
        config.headers.token = localStorage.getItem('token')


    }
    // console.log(config);
    return config
})
Vue.prototype.$http = axios
Vue.config.productionTip = false
Vue.use(Vant);

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')